package hlhj.fhp.checkpoint.module

import android.content.Context
import com.example.mymvp.mvp.BaseModule
import com.lzy.okgo.model.Response
import hlhj.fhp.checkpoint.http.Apis
import hlhj.fhp.checkpoint.http.CustomAction
import hlhj.fhp.checkpoint.http.LoadingAction
import hlhj.fhp.checkpoint.javaBean.ProblemBean

/**
 * Created by Never Fear   on 2018\11\22 0022.
Never More....
 */
class ProblemModule :BaseModule {
    var listener:ProblemListener?=null

    fun getProblem(c:Context,page:Int){
        Apis.getProblems(page)
                ?.let {
                    it.doOnSubscribe(LoadingAction(c))
                            .subscribe(object :CustomAction<Response<ProblemBean>>(c){
                                override fun httpSuccess(t: Response<ProblemBean>) {
                                    listener?.problemResp(t.body())
                                }
                            })
                }
    }

    interface ProblemListener{
        fun problemResp(problemBean: ProblemBean)
    }
}